package com.woniu.controller.healthSystem;

import com.github.pagehelper.PageInfo;
import com.woniu.model.gh.common.Result;
import com.woniu.model.healthSystem.entity.User;
import com.woniu.service.healthSystem.IUserServiceGb;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author gb
 * @since 2023-10-19
 */
@RestController
@RequestMapping("/userHs")
public class UserControllerGb {

    @Autowired
    private IUserServiceGb userService;


    @RequestMapping("/findByPage")
    public Result<PageInfo<User>> findByPage(@RequestBody Map<String,Object> condition) {
        Integer pageNum = (Integer) condition.get("pageNum");
        Integer pageSize = (Integer) condition.get("pageSize");
        PageInfo<User> pageInfo = userService.findByPage(condition,pageNum, pageSize);
        return Result.ok(pageInfo);
    }

    /**
     * 查询所有
     */
    @GetMapping("/findById")
    public Result findAll(Long id) {
        User user = userService.findById(id);
        return Result.ok(user);
    }

}
